package polep.wespace.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import polep.wespace.dao.WeChatPublicNumberDao;
import polep.wespace.model.WeChatPublicNumber;

@Service("wechatPublicNumberService")
public class WeChatPublicNumberService {

	@Resource(name="weChatPublicNumberDao")
	private WeChatPublicNumberDao weChatPublicNumberDao;
	
	public WeChatPublicNumber getFirstWeChatPublicNumber(){
		List<WeChatPublicNumber> list = weChatPublicNumberDao.findWecatPublicNumber(0, 10);
		if(list != null && !list.isEmpty()){
			return list.get(0);
		}
		
		return null;
	}
	
	public boolean updateAccessToken(WeChatPublicNumber weChatPublicNumber){
		int i = weChatPublicNumberDao.updateAccessToken(weChatPublicNumber);
		if(i != 1){
			return false;
		}
		return true;
	}
	
}
